package com.nba.dao.impl;

import java.util.List;

import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import com.nba.bean.Code;
import com.nba.dao.CodeDao;
import com.nba.util.DBUtil;

public class CodeDaoImpl implements CodeDao {
	JdbcTemplate jt = new JdbcTemplate(DBUtil.getDataSource());
	
	@Override
	public Code selectCode(int codeId) {
		String sql = "SELECT * FROM code WHERE code_id = ?";
		List<Code> list = jt.query(sql, new BeanPropertyRowMapper<Code>(Code.class),codeId);
		if(list.size() == 0) {
			return null;
		}else {
			return list.get(0);
		}
	}

}
